import React, { Component, PropTypes } from 'react';
import { ContextMenuLayer } from 'react-contextmenu';
import classNames from 'classnames';

/**
 * 目录节点文本标签
 * @class {TreeItemLabel}
 * @extends {React.Component}
 */
@ContextMenuLayer(
    'tree-view-context-menu',
    props => ({
        isDir: props.isDir, name: props.name, path: props.path
    }))
export default class TreeItemLabel extends Component {
    static propTypes = {
        /**
         * 左键单击事件
         * @type {Function}
         */
         onClick: PropTypes.func,

        /**
         * 文件/文件夹名
         * @type {string}
         */
        name: PropTypes.string,

        /**
         * 路径
         * @type {string}
         */
        path: PropTypes.string,

        /**
         * 是否为文件夹
         * @type {string}
         */
        isDir: PropTypes.bool
    };

    render() {
        const { name, onClick, isDir } = this.props;

        return (
            <span className="label"
                key={"label-" + this.props.path}
                onClick={onClick}>
                {name}
            </span>
        );
    }
}